package com.gisocn.onemap.utils;

import android.util.Log;
import android.util.Xml;
import androidx.exifinterface.media.ExifInterface;
import com.amap.api.services.district.DistrictSearchQuery;
import com.gisocn.onemap.model.AboutSoftware;
import com.gisocn.onemap.model.AppConfig;
import com.gisocn.onemap.model.Download;
import com.gisocn.onemap.model.FileCenter;
import com.gisocn.onemap.model.ManualUrl;
import com.gisocn.onemap.model.UpdateSoftware;
import com.google.gson.Gson;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.regex.Pattern;
import org.achartengine.internal.a;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserFactory;

/* loaded from: classes2.dex */
public class PullHelper {
    /* JADX WARN: Removed duplicated region for block: B:555:0x1a33 A[EXC_TOP_SPLITTER, SYNTHETIC] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct code enable 'Show inconsistent code' option in preferences
    */
    public static java.lang.String getAppConfig(java.io.InputStream r90) throws org.xmlpull.v1.XmlPullParserException {
        /*
            Method dump skipped, instructions count: 10176
            To view this dump change 'Code comments level' option to 'DEBUG'
        */
        throw new UnsupportedOperationException("Method not decompiled: com.gisocn.onemap.utils.PullHelper.getAppConfig(java.io.InputStream):java.lang.String");
    }

    public static String getAppConfigs(InputStream inputStream) throws XmlPullParserException {
        AppConfig appConfig;
        XmlPullParser newPullParser;
        int eventType;
        UpdateSoftware updateSoftware;
        AboutSoftware aboutSoftware;
        ArrayList<Download.NewItem> arrayList;
        Download download;
        AppConfig appConfig2 = null;
        try {
            newPullParser = Xml.newPullParser();
            newPullParser.setInput(inputStream, "UTF-8");
            eventType = newPullParser.getEventType();
            appConfig = new AppConfig();
            updateSoftware = null;
            aboutSoftware = null;
            arrayList = null;
            download = null;
        } catch (IOException e) {
            e = e;
        } catch (XmlPullParserException e2) {
            e = e2;
        }
        while (true) {
            char c = 1;
            if (eventType != 1) {
                if (eventType == 2) {
                    try {
                        String name = newPullParser.getName();
                        switch (name.hashCode()) {
                            case -2105465456:
                                if (name.equals("updateSoftware")) {
                                    c = 4;
                                    break;
                                }
                                c = 65535;
                                break;
                            case -1253954397:
                                if (name.equals("AppConfig")) {
                                    c = 0;
                                    break;
                                }
                                c = 65535;
                                break;
                            case -852475128:
                                if (name.equals("ApplicationTitle")) {
                                    break;
                                }
                                c = 65535;
                                break;
                            case -422279860:
                                if (name.equals("shapeFileWkid")) {
                                    c = '\b';
                                    break;
                                }
                                c = 65535;
                                break;
                            case 3053931:
                                if (name.equals(DistrictSearchQuery.KEYWORDS_CITY)) {
                                    c = 3;
                                    break;
                                }
                                c = 65535;
                                break;
                            case 3242771:
                                if (name.equals("item")) {
                                    c = '\t';
                                    break;
                                }
                                c = 65535;
                                break;
                            case 93521865:
                                if (name.equals("manualUrl")) {
                                    c = '\f';
                                    break;
                                }
                                c = 65535;
                                break;
                            case 106756366:
                                if (name.equals("plist")) {
                                    c = 6;
                                    break;
                                }
                                c = 65535;
                                break;
                            case 132189268:
                                if (name.equals("aboutSoftware")) {
                                    c = '\n';
                                    break;
                                }
                                c = 65535;
                                break;
                            case 837442823:
                                if (name.equals("maplogo")) {
                                    c = 2;
                                    break;
                                }
                                c = 65535;
                                break;
                            case 1427818632:
                                if (name.equals("download")) {
                                    c = 7;
                                    break;
                                }
                                c = 65535;
                                break;
                            case 1949288814:
                                if (name.equals("paragraph")) {
                                    c = 11;
                                    break;
                                }
                                c = 65535;
                                break;
                            case 2143499138:
                                if (name.equals("installSite")) {
                                    c = 5;
                                    break;
                                }
                                c = 65535;
                                break;
                            default:
                                c = 65535;
                                break;
                        }
                        switch (c) {
                            case 0:
                                appConfig.setVersion(newPullParser.getAttributeValue("", "version"));
                                continue;
                            case 1:
                                appConfig.setApplicationTitle(newPullParser.nextText());
                                continue;
                            case 2:
                                appConfig.setMaplogo(newPullParser.getAttributeValue(null, "name"));
                                continue;
                            case 3:
                                appConfig.setCity(newPullParser.nextText());
                                continue;
                            case 4:
                                updateSoftware = new UpdateSoftware();
                                continue;
                            case 5:
                                updateSoftware.setInstallSite(newPullParser.nextText());
                                continue;
                            case 6:
                                updateSoftware.setPlist(newPullParser.nextText());
                                appConfig.setUpdateSoftware(updateSoftware);
                                continue;
                            case 7:
                                download = new Download();
                                arrayList = new ArrayList<>();
                                continue;
                            case '\b':
                            default:
                                continue;
                            case '\t':
                                Download.NewItem newItem = new Download.NewItem();
                                newItem.setcData(newPullParser.nextText());
                                arrayList.add(newItem);
                                download.setItems(arrayList);
                                appConfig.setDownload(download);
                                continue;
                            case '\n':
                                aboutSoftware = new AboutSoftware();
                                aboutSoftware.setTitle(newPullParser.getAttributeValue(null, a.b));
                                continue;
                            case 11:
                                aboutSoftware.setParagraph(newPullParser.nextText());
                                appConfig.setAboutSoftware(aboutSoftware);
                                continue;
                            case '\f':
                                String nextText = newPullParser.nextText();
                                ManualUrl manualUrl = new ManualUrl();
                                manualUrl.setUpdateTime(newPullParser.getAttributeValue(null, "updateTime"));
                                manualUrl.setcData(nextText);
                                appConfig.setManualUrl(manualUrl);
                                continue;
                        }
                    } catch (IOException e3) {
                        e = e3;
                        appConfig2 = appConfig;
                        e.printStackTrace();
                        appConfig = appConfig2;
                        Log.e("appConfig===", new Gson().toJson(appConfig));
                        return new Gson().toJson(appConfig);
                    } catch (XmlPullParserException e4) {
                        e = e4;
                        appConfig2 = appConfig;
                        e.printStackTrace();
                        appConfig = appConfig2;
                        Log.e("appConfig===", new Gson().toJson(appConfig));
                        return new Gson().toJson(appConfig);
                    }
                }
                eventType = newPullParser.next();
            } else {
                Log.e("appConfig===", new Gson().toJson(appConfig));
                return new Gson().toJson(appConfig);
            }
        }
    }

    private static boolean checkAttribute(XmlPullParser xmlPullParser, String str, int i) {
        return xmlPullParser.getAttributeCount() >= i && xmlPullParser.getAttributeName(i).equals(str);
    }

    /* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */
    /* JADX WARN: Code restructure failed: missing block: B:23:0x0056, code lost:
        if (r9.equals("commands") == false) goto L8;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct code enable 'Show inconsistent code' option in preferences
    */
    public static com.gisocn.onemap.model.QueryXML getQueryXML(java.io.InputStream r12) throws org.xmlpull.v1.XmlPullParserException, java.io.IOException {
        /*
            org.xmlpull.v1.XmlPullParserFactory r0 = org.xmlpull.v1.XmlPullParserFactory.newInstance()
            org.xmlpull.v1.XmlPullParser r0 = r0.newPullParser()
            java.lang.String r1 = "UTF-8"
            r0.setInput(r12, r1)
            int r12 = r0.getEventType()
            r1 = 0
            r2 = r1
            r3 = r2
            r4 = r3
        L15:
            r5 = 1
            if (r12 == r5) goto Lc6
            java.lang.String r6 = "fields"
            r7 = 3
            r8 = 2
            if (r12 != r8) goto La8
            java.lang.String r9 = r0.getName()
            r9.hashCode()
            r10 = -1
            int r11 = r9.hashCode()
            switch(r11) {
                case -1274708295: goto L59;
                case -602535288: goto L50;
                case 114126: goto L45;
                case 97427706: goto L3a;
                case 106006350: goto L2f;
                default: goto L2d;
            }
        L2d:
            r5 = -1
            goto L61
        L2f:
            java.lang.String r5 = "order"
            boolean r5 = r9.equals(r5)
            if (r5 != 0) goto L38
            goto L2d
        L38:
            r5 = 4
            goto L61
        L3a:
            java.lang.String r5 = "field"
            boolean r5 = r9.equals(r5)
            if (r5 != 0) goto L43
            goto L2d
        L43:
            r5 = 3
            goto L61
        L45:
            java.lang.String r5 = "sql"
            boolean r5 = r9.equals(r5)
            if (r5 != 0) goto L4e
            goto L2d
        L4e:
            r5 = 2
            goto L61
        L50:
            java.lang.String r8 = "commands"
            boolean r8 = r9.equals(r8)
            if (r8 != 0) goto L61
            goto L2d
        L59:
            boolean r5 = r9.equals(r6)
            if (r5 != 0) goto L60
            goto L2d
        L60:
            r5 = 0
        L61:
            switch(r5) {
                case 0: goto L9e;
                case 1: goto L98;
                case 2: goto L88;
                case 3: goto L6d;
                case 4: goto L65;
                default: goto L64;
            }
        L64:
            goto La8
        L65:
            java.lang.String r5 = r0.nextText()
            r2.setOrder(r5)
            goto La8
        L6d:
            com.gisocn.onemap.model.QueryXML$Field r5 = new com.gisocn.onemap.model.QueryXML$Field
            r5.<init>()
            java.lang.String r8 = "name"
            java.lang.String r8 = r0.getAttributeValue(r1, r8)
            r5.setName(r8)
            java.lang.String r8 = "aliasname"
            java.lang.String r8 = r0.getAttributeValue(r1, r8)
            r5.setAliasname(r8)
            r3.add(r5)
            goto La8
        L88:
            com.gisocn.onemap.model.QueryXML$SQL r5 = new com.gisocn.onemap.model.QueryXML$SQL
            r5.<init>()
            java.lang.String r8 = r0.nextText()
            r5.setcData(r8)
            r4.add(r5)
            goto La8
        L98:
            java.util.ArrayList r4 = new java.util.ArrayList
            r4.<init>()
            goto La8
        L9e:
            com.gisocn.onemap.model.QueryXML r2 = new com.gisocn.onemap.model.QueryXML
            r2.<init>()
            java.util.ArrayList r3 = new java.util.ArrayList
            r3.<init>()
        La8:
            if (r12 != r7) goto Lc0
            java.lang.String r12 = r0.getName()
            r12.hashCode()
            boolean r12 = r12.equals(r6)
            if (r12 != 0) goto Lb8
            goto Lc0
        Lb8:
            if (r2 == 0) goto Lc0
            r2.setFields(r3)
            r2.setCommands(r4)
        Lc0:
            int r12 = r0.next()
            goto L15
        Lc6:
            return r2
        */
        throw new UnsupportedOperationException("Method not decompiled: com.gisocn.onemap.utils.PullHelper.getQueryXML(java.io.InputStream):com.gisocn.onemap.model.QueryXML");
    }

    public static ArrayList<FileCenter> getFileCenter(InputStream inputStream) throws IOException {
        ArrayList<FileCenter> arrayList = null;
        try {
            XmlPullParser newPullParser = XmlPullParserFactory.newInstance().newPullParser();
            newPullParser.setInput(inputStream, "UTF-8");
            ArrayList<FileCenter> arrayList2 = null;
            for (int eventType = newPullParser.getEventType(); eventType != 1; eventType = newPullParser.next()) {
                if (eventType == 2) {
                    try {
                        if (!newPullParser.getName().equals("pre")) {
                            String name = newPullParser.getName();
                            char c = 65535;
                            if (name.hashCode() == 65 && name.equals(ExifInterface.GPS_MEASUREMENT_IN_PROGRESS)) {
                                c = 0;
                            }
                            String attributeValue = newPullParser.getAttributeValue(null, "HREF");
                            String nextText = newPullParser.nextText();
                            if (!attributeValue.equals("/") && !attributeValue.contains("web.config")) {
                                FileCenter fileCenter = new FileCenter();
                                fileCenter.setName(nextText);
                                if (nextText.contains(".")) {
                                    Log.e("contains", nextText.substring(nextText.lastIndexOf(".") + 1));
                                    if (isNumeric(nextText.substring(nextText.lastIndexOf(".") + 1))) {
                                        fileCenter.setType(1);
                                    } else {
                                        fileCenter.setType(0);
                                    }
                                } else {
                                    fileCenter.setType(1);
                                }
                                fileCenter.setHerf(attributeValue);
                                if (arrayList2 == null) {
                                    arrayList2 = new ArrayList<>();
                                }
                                arrayList2.add(fileCenter);
                            }
                        }
                    } catch (XmlPullParserException e) {
                        e = e;
                        arrayList = arrayList2;
                        e.printStackTrace();
                        return arrayList;
                    }
                }
            }
            return arrayList2;
        } catch (XmlPullParserException e2) {
            e = e2;
        }
    }

    public static boolean isNumeric(String str) {
        return Pattern.compile("[0-9]*").matcher(str).matches();
    }
}
